﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hsp.Net4.Common.LogUtil
{
    public interface ILogEventHandler
    {
        void LogEventHandler(LogEventArgs e);
    }
    public enum LogLevel
    {
        DEBUG, ERROR, WARN, INFO, FATAL
    }
    public sealed class LogEventArgs : EventArgs
    {
        private Exception ex = null;
        private LogLevel level = LogLevel.DEBUG;
        private Type type = null;
        private String msg = String.Empty;
        public LogEventArgs(Type type, LogLevel lvl, String msg, Exception ex)
        {
            this.level = lvl;
            this.msg = msg;
            this.type = type;
            this.ex = ex;
        }
        public Type Type
        {
            get { return this.type; }
        }
        public Exception Ex
        {
            get { return this.ex; }
            set { this.ex = value; }
        }
        public LogLevel Level
        {
            get { return this.level; }
        }
        public String Msg
        {
            get { return this.msg; }
            set { this.msg = value; }
        }
        public override string ToString()
        {
            return this.type == null ? Msg : this.type.ToString() + ":" + Msg;
        }
    }
    public delegate void LogEventHandler(LogEventArgs e);
}
